package com.tydic.serviceprovider.controller;

import com.tydic.helloserviceapi.domain.Goods;
import com.tydic.helloserviceapi.service.HelloServiceApi;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Description: 重构后的controller
 * @Author: xuwenguang
 * @CreateDate: 2019/3/6 14:15
 * @UpdateUser: xuwenguang
 * @UpdateDate: 2019/3/6 14:15
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@RestController
public class RefactorHelloController implements HelloServiceApi {
    @Override
    public String hello(@RequestParam("name")String name) {
        return "hello:"+name;
    }

    @Override
    public Goods hello(@RequestHeader("name")String name, @RequestHeader("price")BigDecimal price) {
        return new Goods(name,price);
    }

    @Override
    public String hello(@RequestBody  Goods goods) {
        return "hello:"+goods.getName()+"--"+goods.getPrice();
    }
}
